----------------------------
-- Simplistic Street
-- by Jammie Dodger
--
-- Project Started - October 20, 2009
-- Completion -None
----------------------------

START_CASH = 250

function _R.Player:Save()

	self:SetPData("Money", self:GetMoney())

end

function _R.Player:Load()

	self:SetNWInt("Money", self:GetPData("Money") or START_CASH)

end

function _R.Player:GetMoney()

	return self:GetNWInt("Money")

end

function _R.Player:CanAfford( Money )

	return (self:GetMoney() - Money) >= 0
	
end

function _R.Player:TakeMoney( Money )

	self:SetMoney( tonumber(self:GetMoney()) - tonumber(Money))
	self:Save()
	
end

function _R.Player:GiveMoney( Money )

	self:SetMoney( tonumber(self:GetMoney()) + tonumber(Money))
	self:Save()
	
end

function _R.Player:SetMoney(amount)

	self:SetNWInt("Money", amount)
	self:Save()

end

function Payday()

for k,v in pairs(player.GetAll()) do
	if v:Team() == 1 then 
		v:GiveMoney(35)
		v:SendNotify("Your employer sent you a check for $35!", NOTIFY_GENERIC, 4)
	elseif v:Team() == 2 then
		v:GiveMoney(75)
		v:SendNotify("Your employer sent you a check for $75", NOTIFY_GENERIC, 4)
		end
	end
end

timer.Create( "Payday", 120, 0, Payday )

function FindPlayer(info)
	local pls = player.GetAll()

	for k, v in pairs(pls) do
		if tonumber(info) == v:UserID() then
			return v
		end
	end

	for k, v in pairs(pls) do
		if info == v:SteamID() then
			return v
		end
	end
	
	for k, v in pairs(pls) do
		if string.find(string.lower(v:Name()), string.lower(tostring(info)), 1, true) ~= nil then
			return v
		end
	end
	return nil
end